#include "Rational.h"
#include <sstream>

namespace TreeExpression {

Rational::Rational(int _num, int _den) : Expression_CRTP<Rational>(), num(_num), den(_den) { }

Rational::Rational(const Rational& copy) : Expression(copy), Expression_CRTP<Rational>(copy) {
	num = copy.num;
	den = copy.den;
}

Rational::~Rational() { }

AutoPointer<Expression> Rational::eval(CopyPointer<Context>&) {
	return AutoPointer<Expression>(new TreeExpression::Rational(*this));
}

int Rational::getNumerator() const {
	return num;
}

int Rational::getDenominator() const {
	return den;
}

std::string Rational::getHash() const {
	return "Rational";
}

std::string Rational::toString() const {
	std::ostringstream oss;
	oss << num << "/" << den;
	return oss.str();
}

}

